package com.fivestar.pmanager.dao.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import com.fivestar.pmanager.core.mapper.DBActionMapper;
import com.fivestar.pmanager.core.mapper.PaginatingMapper;
import com.fivestar.pmanager.model.SysRoleModuleBean;

/**
 * 角色模块
 * SysRoleModuleMapper
 * @author 
 */
@Repository("sysRoleModuleMapper")
public interface SysRoleModuleMapper extends DBActionMapper<SysRoleModuleBean>,
        PaginatingMapper<SysRoleModuleBean>
{
	/**
	 * 只删除一级模块对应关系
	 * @param roleId
	 * @return
	 */
	@Delete("delete from sys_role_module where role_id = #{roleId}")
	int deleteRoleModuleByRoleId(@Param("roleId") int roleId);
	
	/**
	 * 子菜单 权限的 清除
	 * @param roleId
	 * @return
	 */
	@Delete("delete rm from sys_role_module rm " +
			" inner join sys_module m on rm.module_id = m.row_id " +
			" where rm.role_id = #{roleId} and m.parent_id != -1")
	int deleteRolePrivilegeByRoleId(@Param("roleId") int roleId);
}
